<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    347. Top K Frequent Elements
   </h1>
   <p>
    Given a non-empty array of integers, return the
    <b>
     <i>
      k
     </i>
    </b>
    most frequent elements.
   </p>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input: </strong>nums = <span id="example-input-1-1">[1,1,1,2,2,3]</span>, k = <span id="example-input-1-2">2</span>
<strong>Output: </strong><span id="example-output-1">[1,2]</span>
</pre>
   <div>
    <p>
     <strong>
      Example 2:
     </strong>
    </p>
    <pre>
<strong>Input: </strong>nums = <span id="example-input-2-1">[1]</span>, k = <span id="example-input-2-2">1</span>
<strong>Output: </strong><span id="example-output-2">[1]</span></pre>
   </div>
   <p>
    <b>
     Note:
    </b>
   </p>
   <ul>
    <li>
     You may assume
     <i>
      k
     </i>
     is always valid, 1 &le;
     <i>
      k
     </i>
     &le; number of unique elements.
    </li>
    <li>
     Your algorithm's time complexity
     <b>
      must be
     </b>
     better than O(
     <i>
      n
     </i>
     log
     <i>
      n
     </i>
     ), where
     <i>
      n
     </i>
     is the array's size.
    </li>
   </ul>
  </div>
  <div>
   <h1 class="question_title">
    347. 前K个高频元素
   </h1>
   <p>
    给定一个非空的整数数组，返回其中出现频率前&nbsp;
    <strong>
     <em>
      k&nbsp;
     </em>
    </strong>
    高的元素。
   </p>
   <p>
    <strong>
     示例 1:
    </strong>
   </p>
   <pre><strong>输入: </strong>nums = [1,1,1,2,2,3], k = 2
<strong>输出: </strong>[1,2]
</pre>
   <p>
    <strong>
     示例 2:
    </strong>
   </p>
   <pre><strong>输入: </strong>nums = [1], k = 1
<strong>输出: </strong>[1]</pre>
   <p>
    <strong>
     说明：
    </strong>
   </p>
   <ul>
    <li>
     你可以假设给定的&nbsp;
     <em>
      k&nbsp;
     </em>
     总是合理的，且 1 &le; k &le; 数组中不相同的元素的个数。
    </li>
    <li>
     你的算法的时间复杂度
     <strong>
      必须
     </strong>
     优于 O(
     <em>
      n
     </em>
     log
     <em>
      n
     </em>
     ) ,&nbsp;
     <em>
      n&nbsp;
     </em>
     是数组的大小。
    </li>
   </ul>
  </div>
 </body>
</html>